package muview;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

import mumethod.AccessPhysicals;
import mumethod.AccessQuestionnaires;
import mumethod.AccessQuestions;
import mumethod.AccessStudents;
import mumethod.Base64String;
import mumethod.LibFunction;
import mumethod.DateControl;
import mumethod.PreviewReport;
import mumethod.ReportGenerator;
import muobject.Physical;
import muobject.PhysicalSimpleSummary;
import muobject.Questionnaire;
import muobject.SystemProperty;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.springframework.context.ApplicationContext;

import com.cloudgarden.resource.SWTResourceManager;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class TeacherReport extends Composite{

	{
		//Register as a resource user - SWTResourceManager will
		//handle the obtaining and disposing of resources
		SWTResourceManager.registerResourceUser(this);
	}
	

	private Label lab_report;
	private Label lab_reportdatayear;
	private Label lab_reportdatagarde;
	private Label lab_reportdataclass;
	private Label lab_reportdatastudent;
	private Label lab_reportdatablank;
	private Label lab_reportphyical;
	private Label lab_reportdquestion;
	private Label lab_reportfquestion;
	private Label lab_reporttotal;
	private Table tabledataYear;
	private Table tabledataGrade;
	private Table tabledataClass;
	private Table tabledataStudent;
	private Button but_pdataprint;
	private Button but_qdataprint;
	private Button but_calculator;
	private Button but_datasampleprint;
	private Button but_reportphyicalsex;
	private Button but_reportdquestionsex;
	private Button but_reportfquestionsex;
	private Button but_reporttotalsex;
	
	private List<Physical> physicals;
	private List<Questionnaire> questionnaires;
	
	private ApplicationContext springConnector;
	private AccessStudents getStudents;
	private AccessPhysicals getPhysicals;
	private AccessQuestionnaires getQuestionnaires;
	private AccessQuestions getQuestions;
	private List<String> years;
	private List<String> grades;
	private List<String> sclasses;
	private Map<String, String> studentstno;
	private String sno;
	private String year;
	private String grade;
	private String sclass;
	private Boolean editFlat;
	private String currentYear;
	private String currentMonth;
	private String imagePath;
	private String templatePath;
	private String selectStudentNo;
	private Base64String Base64;
	private Color selectColor;
	private Color nonSelectColor;
	private int selectColumn;
	private Image calendarImage;
	private Shell shell;
	private Combo cmb_month;
	private DateControl dateControl;
	private TableItem item;
	private ReportGenerator getReportGenerator;
	private PreviewReport previewReport;;
	
	public void Init(SystemProperty systemProperty, Shell shellLocal) {
		springConnector = systemProperty.getSpringConnector();
		getStudents = (AccessStudents) springConnector
				.getBean("AccessStudentsService");
		getPhysicals = (AccessPhysicals)springConnector
				.getBean("AccessPhysicalsService");
		getQuestionnaires = (AccessQuestionnaires)springConnector
				.getBean("AccessQuestionnairesService");
		getQuestions = (AccessQuestions)springConnector
				.getBean("AccessQuestionsService");
		getReportGenerator = (ReportGenerator)springConnector
				.getBean("ReportGeneratorService");
		previewReport = (PreviewReport)springConnector
				.getBean("PreviewReportService");
		year = systemProperty.getYear();
		sno = systemProperty.getSno();
		grade = systemProperty.getGrade();
		sclass = systemProperty.getSclass();
		editFlat = systemProperty.getYear().substring(0, 4)
				.equals(systemProperty.getCurrentYear());
		currentYear = systemProperty.getCurrentYear();
		templatePath = systemProperty.getTemplatePath();
		imagePath = systemProperty.getImagePath();
		Base64 = new LibFunction();
		selectColor = new Color(this.getDisplay(), 135,206,250);
		nonSelectColor = new Color(this.getDisplay(), 255,255,255);
		ImageData date = new ImageData(imagePath + "calendar.png");
		date.scaledTo(10, 10);
		calendarImage = new Image(this.getDisplay(), date);
		shell = shellLocal;
		dateControl = new LibFunction();
		years = new ArrayList<String>();
		grades = new ArrayList<String>();
		sclasses = new ArrayList<String>();
		studentstno = new TreeMap<String, String>();
	}
	
	public TeacherReport(Composite c, final Shell shell, SystemProperty systemProperty) {
		super(c, SWT.BORDER);
		Init(systemProperty, shell);
		FillLayout CompositeFormLayout = new FillLayout();
		this.setLayout(CompositeFormLayout);
		this.setSize(990, 520);
		{
			Composite composite = new Composite(this, SWT.NONE);
			GridLayout compositeLayout = new GridLayout();
			compositeLayout.numColumns = 8;
			compositeLayout.makeColumnsEqualWidth = true;
			composite.setLayout(compositeLayout);
			{
				{
					lab_report = new Label(composite, SWT.NONE);
					GridData lab_reportLData = new GridData();
					lab_reportLData.horizontalSpan = 8;
					lab_reportLData.verticalAlignment = GridData.END;
					lab_report.setLayoutData(lab_reportLData);
					lab_report.setText("\u5b78\u751f\u8cc7\u6599\u5831\u8868");
					lab_report.setFont(SWTResourceManager.getFont("Tahoma", 20, 1, false, false));
				}
				{
					GridData pageCompositeGridData = new GridData();
					pageCompositeGridData.widthHint = 975;
					pageCompositeGridData.heightHint = 460;
					pageCompositeGridData.horizontalSpan = 8;
					Composite pageComposite = new Composite(composite, SWT.NONE);
					pageComposite.setLayoutData(pageCompositeGridData);
					pageComposite.setLayout(new FillLayout());
					{
						final CTabFolder tabpageFolder = new CTabFolder(pageComposite,
								SWT.BORDER);
						tabpageFolder.setSimple(false);
						tabpageFolder.setBackgroundMode(SWT.INHERIT_DEFAULT);
						CTabItem one = new CTabItem(tabpageFolder, SWT.NONE);
						one.setText("學生資料數據報表   ");
						one.setToolTipText("");
						one.setFont(SWTResourceManager.getFont("Tahoma", 12, 1, false,
								false));
						one.setControl(gettabpageOneControl(tabpageFolder));

						CTabItem two = new CTabItem(tabpageFolder, SWT.NONE);
						two.setText("學生資料分析報表  ");
						two.setToolTipText("");
						two.setFont(SWTResourceManager.getFont("Tahoma", 12, 1, false,
								false));
						two.setControl(gettabpageTwoControl(tabpageFolder));

						tabpageFolder.setSelection(0);
					}
				}
			}
		}
	}
	
	private Composite gettabpageOneControl(CTabFolder tabpageFolder) {
		Composite dataReportComposite;
		dataReportComposite = new Composite(tabpageFolder, SWT.NONE);
		GridLayout dataReportCompositeLayout = new GridLayout();
		dataReportCompositeLayout.makeColumnsEqualWidth = true;
		dataReportCompositeLayout.numColumns = 10;
		dataReportCompositeLayout.marginWidth = 20;
		dataReportComposite.setLayout(dataReportCompositeLayout);
		{
			{
				lab_reportdatayear = new Label(dataReportComposite, SWT.NONE);
				GridData lab_reportdatayearLData = new GridData();
				lab_reportdatayearLData.horizontalSpan = 2;
				lab_reportdatayearLData.widthHint = 200;
				lab_reportdatayearLData.verticalAlignment = GridData.END;
				lab_reportdatayear.setLayoutData(lab_reportdatayearLData);
				lab_reportdatayear.setText("\u5e74\u4efd");
				lab_reportdatayear.setFont(SWTResourceManager.getFont("Tahoma", 16, 1, false, false));
				lab_reportdatayear.setAlignment(SWT.CENTER);
			}
			{
				lab_reportdatagarde = new Label(dataReportComposite, SWT.NONE);
				GridData lab_reportdatagardeLData = new GridData();
				lab_reportdatagardeLData.horizontalSpan = 2;
				lab_reportdatagardeLData.widthHint = 200;
				lab_reportdatagardeLData.verticalAlignment = GridData.END;
				lab_reportdatagarde.setLayoutData(lab_reportdatagardeLData);
				lab_reportdatagarde.setText("\u73ed\u7d1a");
				lab_reportdatagarde.setFont(SWTResourceManager.getFont("Tahoma", 16, 1, false, false));
				lab_reportdatagarde.setAlignment(SWT.CENTER);
			}
			{
				lab_reportdataclass = new Label(dataReportComposite, SWT.NONE);
				GridData lab_reportdataclassLData = new GridData();
				lab_reportdataclassLData.horizontalSpan = 2;
				lab_reportdataclassLData.widthHint = 200;
				lab_reportdataclassLData.verticalAlignment = GridData.END;
				lab_reportdataclass.setLayoutData(lab_reportdataclassLData);
				lab_reportdataclass.setText("\u73ed\u5225");
				lab_reportdataclass.setFont(SWTResourceManager.getFont("Tahoma", 16, 1, false, false));
				lab_reportdataclass.setAlignment(SWT.CENTER);
			}
			{
				lab_reportdatastudent = new Label(dataReportComposite, SWT.NONE);
				GridData lab_reportdatastudentLData = new GridData();
				lab_reportdatastudentLData.horizontalSpan = 2;
				lab_reportdatastudentLData.widthHint = 200;
				lab_reportdatastudentLData.verticalAlignment = GridData.END;
				lab_reportdatastudent.setLayoutData(lab_reportdatastudentLData);
				lab_reportdatastudent.setText("\u5b78\u751f");
				lab_reportdatastudent.setFont(SWTResourceManager.getFont("Tahoma", 16, 1, false, false));
				lab_reportdatastudent.setAlignment(SWT.CENTER);
			}
			{
				lab_reportdatablank = new Label(dataReportComposite, SWT.NONE);
				GridData lab_reportdatablankLData = new GridData();
				lab_reportdatablankLData.horizontalSpan = 2;
				lab_reportdatablankLData.widthHint = 100;
				lab_reportdatablankLData.verticalAlignment = GridData.END;
				lab_reportdatablankLData.horizontalAlignment = GridData.CENTER;
				lab_reportdatablank.setLayoutData(lab_reportdatablankLData);
				lab_reportdatablank.setFont(SWTResourceManager.getFont("Tahoma", 16, 1, false, false));
			}
//-------------------------------------------------------------------------------------------------
			{
				GridData tabledataYearLData = new GridData();
				tabledataYearLData.horizontalSpan = 2;
				tabledataYearLData.verticalAlignment = GridData.END;
				tabledataYearLData.horizontalAlignment = SWT.CENTER;
				tabledataYearLData.widthHint = 150;
				tabledataYearLData.heightHint = 350;
				tabledataYear = new Table(dataReportComposite, SWT.CHECK
						| SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
				tabledataYear.setHeaderVisible(true);
				tabledataYear.setLinesVisible(true);
				tabledataYear.setFont(SWTResourceManager.getFont("Tahoma", 9, 0, false,
						false));
				tabledataYear.setLayoutData(tabledataYearLData);
				{
					TableColumn column = new TableColumn(tabledataYear,  SWT.CENTER);
				    column.setText("年份");
					column.setWidth(150);
					column.setAlignment(SWT.CENTER);
					 
					tableYearGetData();
					tabledataYear.addListener(SWT.Selection, new Listener() {
					      public void handleEvent(Event e) {
					    	  tabledataGrade.removeAll();
					    	  tabledataClass.removeAll();
					    	  tabledataStudent.removeAll();
					    	  tableGradeGetData();
					      }
					 });
				}
			}
			{
				GridData tabledataGradeLData = new GridData();
				tabledataGradeLData.horizontalSpan = 2;
				tabledataGradeLData.verticalAlignment = GridData.END;
				tabledataGradeLData.horizontalAlignment = SWT.CENTER;
				tabledataGradeLData.widthHint = 150;
				tabledataGradeLData.heightHint = 350;
				tabledataGrade = new Table(dataReportComposite, SWT.CHECK
						| SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
				tabledataGrade.setHeaderVisible(true);
				tabledataGrade.setLinesVisible(true);
				tabledataGrade.setFont(SWTResourceManager.getFont("Tahoma", 9, 0, false,
						false));
				tabledataGrade.setLayoutData(tabledataGradeLData);
				{
					TableColumn column = new TableColumn(tabledataGrade,  SWT.CENTER);
				    column.setText("班級");
					column.setWidth(150);
					column.setAlignment(SWT.CENTER);

					tableGradeGetData();
					tabledataGrade.addListener(SWT.Selection, new Listener() {
					      public void handleEvent(Event e) {
					    	  tabledataClass.removeAll();
					    	  tabledataStudent.removeAll();
					    	  tableClassGetData();
					      }
					 });
				}
			}
			{
				GridData tabledataClassLData = new GridData();
				tabledataClassLData.horizontalSpan = 2;
				tabledataClassLData.verticalAlignment = GridData.END;
				tabledataClassLData.horizontalAlignment = SWT.CENTER;
				tabledataClassLData.widthHint = 150;
				tabledataClassLData.heightHint = 350;
				tabledataClass = new Table(dataReportComposite, SWT.CHECK
						| SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
				tabledataClass.setHeaderVisible(true);
				tabledataClass.setLinesVisible(true);
				tabledataClass.setFont(SWTResourceManager.getFont("Tahoma", 9, 0, false,
						false));
				tabledataClass.setLayoutData(tabledataClassLData);
				{
					TableColumn column = new TableColumn(tabledataClass,  SWT.CENTER);
				    column.setText("班別");
					column.setWidth(150);
					column.setAlignment(SWT.CENTER);

					tableClassGetData();
					tabledataClass.addListener(SWT.Selection, new Listener() {
					      public void handleEvent(Event e) {
					    	  tabledataStudent.removeAll();
					    	  tableStudentGetData();
					      }
					 });
				}
			}
			{
				GridData tabledataStudentLData = new GridData();
				tabledataStudentLData.horizontalSpan = 2;
				tabledataStudentLData.verticalAlignment = GridData.END;
				tabledataStudentLData.horizontalAlignment = SWT.CENTER;
				tabledataStudentLData.widthHint = 150;
				tabledataStudentLData.heightHint = 350;
				tabledataStudent = new Table(dataReportComposite, SWT.CHECK
						| SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
				tabledataStudent.setHeaderVisible(true);
				tabledataStudent.setLinesVisible(true);
				tabledataStudent.setFont(SWTResourceManager.getFont("Tahoma", 9, 0, false,
						false));
				tabledataStudent.setLayoutData(tabledataStudentLData);
				{
					TableColumn column = new TableColumn(tabledataStudent,  SWT.CENTER);
				    column.setText("學生");
				    TableColumn columnstno = new TableColumn(tabledataStudent,  SWT.CENTER);
				    columnstno.setText("學生編號");
					column.setWidth(90);
					columnstno.setWidth(75);
					column.setAlignment(SWT.CENTER);

					tableStudentGetData();
				}
			}
			{
				Composite dataReportButtonComposite;
				dataReportButtonComposite = new Composite(dataReportComposite, SWT.NONE);
				GridLayout dataReportButtonCompositeLayout = new GridLayout();
				GridData dataReportButtonCompositeLData = new GridData();
				dataReportButtonCompositeLData.horizontalSpan = 2;
				dataReportButtonCompositeLData.widthHint = 110;
				dataReportButtonCompositeLData.verticalAlignment = GridData.END;
				dataReportButtonComposite.setLayout(dataReportButtonCompositeLayout);
				dataReportButtonComposite.setLayoutData(dataReportButtonCompositeLData);
				{
					GridData but_calculatorLData = new GridData();
					but_calculatorLData.widthHint = 103;
					but_calculatorLData.verticalAlignment = GridData.END;
					but_calculatorLData.heightHint = 69;
					but_calculator = new ReturnButton(dataReportButtonComposite, SWT.WRAP | SWT.PUSH
							| SWT.CENTER);
					but_calculator.setText("  \u8cc7\u6599 \n  \u8a08\u7b97");
					but_calculator.setFont(SWTResourceManager.getFont("Tahoma", 16, 1, false, false));
					but_calculator.setLayoutData(but_calculatorLData);
					but_calculator.setAlignment(SWT.CENTER);
					but_calculator
							.addSelectionListener(new SelectionAdapter() {
								public void widgetSelected(SelectionEvent e) {
									try {
										previewReport.DataCalaulator(sno, getTableCheck(tabledataYear), getTableCheck(tabledataGrade), 
												getTableCheck(tabledataClass), getTableCheck(tabledataStudent));
									} catch (Exception e1) {
										e1.printStackTrace();
									}
									if (!previewReport.ExistDataTable()){
										but_pdataprint.setEnabled(false);
									    but_qdataprint.setEnabled(false);
									    but_datasampleprint.setEnabled(false);
									}
									else{
										but_pdataprint.setEnabled(true);
									    but_qdataprint.setEnabled(true);
									    but_datasampleprint.setEnabled(true);
									}
								}
							});
				}
				{
					GridData but_pdataprintLData = new GridData();
					but_pdataprintLData.widthHint = 103;
					but_pdataprintLData.verticalAlignment = GridData.END;
					but_pdataprintLData.heightHint = 69;
					but_pdataprint = new ReturnButton(dataReportButtonComposite, SWT.WRAP | SWT.PUSH
							| SWT.CENTER);
					but_pdataprint.setText("\u9ad4\u9069\u80fd\n\u8a55\u5206\u8868");
					but_pdataprint.setFont(SWTResourceManager.getFont("Tahoma", 16, 1, false, false));
					but_pdataprint.setLayoutData(but_pdataprintLData);
					but_pdataprint.setAlignment(SWT.CENTER);
					but_pdataprint
							.addSelectionListener(new SelectionAdapter() {
								public void widgetSelected(SelectionEvent e) {
									
									try {
										previewReport.PhysicalSampleSummaryDisplay(sno, getTableCheck(tabledataYear), getTableCheck(tabledataGrade), 
												getTableCheck(tabledataClass), getTableCheck(tabledataStudent));
									} catch (Exception e1) {
										e1.printStackTrace();
									}
									
								}
							});
					if (!previewReport.ExistDataTable())
						but_pdataprint.setEnabled(false);
					else
						but_pdataprint.setEnabled(true);
				}
				{
					GridData but_qdataprintLData = new GridData();
					but_qdataprintLData.widthHint = 105;
					but_qdataprintLData.verticalAlignment = GridData.END;
					but_qdataprintLData.heightHint = 70;
					but_qdataprint = new ReturnButton(dataReportButtonComposite, SWT.PUSH
							| SWT.CENTER | SWT.WRAP);
					but_qdataprint.setText("\u5065\u5eb7\u554f\n\u5377\u5831\u8868");
					but_qdataprint.setFont(SWTResourceManager.getFont("Tahoma", 16, 1, false, false));
					but_qdataprint.setLayoutData(but_qdataprintLData);
					but_qdataprint.setAlignment(SWT.CENTER);
					but_qdataprint
							.addSelectionListener(new SelectionAdapter() {
								public void widgetSelected(SelectionEvent e) {
									try {
										previewReport.QuestionnaireSampleSummaryDisplay(sno, getTableCheck(tabledataYear), getTableCheck(tabledataGrade), 
												getTableCheck(tabledataClass), getTableCheck(tabledataStudent));
									} catch (Exception e1) {
										e1.printStackTrace();
									}
								}
							});
					if (!previewReport.ExistDataTable())
						but_qdataprint.setEnabled(false);
					else
						but_qdataprint.setEnabled(true);
				}
				{
					GridData but_datasampleprintLData = new GridData();
					but_datasampleprintLData.horizontalSpan = 1;
					but_datasampleprintLData.widthHint = 105;
					but_datasampleprintLData.verticalAlignment = GridData.END;
					but_datasampleprintLData.heightHint = 70;
					but_datasampleprintLData.horizontalAlignment = SWT.LEFT;
					but_datasampleprint = new ReturnButton(dataReportButtonComposite, SWT.PUSH
							| SWT.CENTER | SWT.WRAP);
					but_datasampleprint.setText("\u5b78\u751f\u500b\n\u4eba\u5831\u8868");
					but_datasampleprint.setFont(SWTResourceManager.getFont("Tahoma", 16, 1, false, false));
					but_datasampleprint.setLayoutData(but_datasampleprintLData);
					but_datasampleprint.setAlignment(SWT.CENTER);
					but_datasampleprint
							.addSelectionListener(new SelectionAdapter() {
								public void widgetSelected(SelectionEvent e) {
									try {
										previewReport.StudentSummaryDisplay();
									} catch (Exception e1) {
										e1.printStackTrace();
									}
								}
							});
					if (!previewReport.ExistDataTable())
						but_datasampleprint.setEnabled(false);
					else
						but_datasampleprint.setEnabled(true);
				}
			}
				
		}
		return dataReportComposite;
	}

	private Composite gettabpageTwoControl(CTabFolder tabpageFolder) {
		Composite dataReportComposite;
		dataReportComposite = new Composite(tabpageFolder, SWT.NONE);
		GridLayout dataReportCompositeLayout = new GridLayout();
		dataReportCompositeLayout.makeColumnsEqualWidth = true;
		dataReportCompositeLayout.numColumns = 10;
		dataReportCompositeLayout.marginWidth = 20;
		dataReportComposite.setLayout(dataReportCompositeLayout);
		{
			{
				lab_reportphyical = new Label(dataReportComposite, SWT.NONE);
				GridData lab_reportphyicalLData = new GridData();
				lab_reportphyicalLData.horizontalSpan = 8;
				lab_reportphyicalLData.widthHint = 750;
				lab_reportphyicalLData.heightHint = 51;
				lab_reportphyicalLData.horizontalAlignment = GridData.BEGINNING;
				lab_reportphyical.setLayoutData(lab_reportphyicalLData);
				lab_reportphyical.setText("\u9ad4\u9069\u80fd\u8cc7\u6599\u5206\u6790");
				lab_reportphyical.setFont(SWTResourceManager.getFont("Tahoma", 26, 1, false, false));
			}
			{
				but_reportphyicalsex = new Button(dataReportComposite, SWT.NONE);
				GridData but_reportphyicalsexLData = new GridData();
				but_reportphyicalsexLData.horizontalSpan = 2;
				but_reportphyicalsexLData.widthHint = 150;
				but_reportphyicalsexLData.heightHint = 100;
				but_reportphyicalsexLData.verticalAlignment = GridData.END;
				but_reportphyicalsex.setLayoutData(but_reportphyicalsexLData);
				but_reportphyicalsex.setText("\u6027\u5225\u5c0d\u6bd4\u5206\u6790");
				but_reportphyicalsex.setFont(SWTResourceManager.getFont("Tahoma", 16, 1, false, false));
				but_reportphyicalsex.setAlignment(SWT.CENTER);
				but_reportphyicalsex
				.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(SelectionEvent e) {
						try {
							previewReport.PhysicalSexChartDisplay();
						} catch (Exception e1) {
							e1.printStackTrace();
						}
					}
				});
			}
			{
				lab_reportdquestion = new Label(dataReportComposite, SWT.NONE);
				GridData lab_reportdquestionLData = new GridData();
				lab_reportdquestionLData.horizontalSpan = 8;
				lab_reportdquestionLData.widthHint = 750;
				lab_reportdquestionLData.heightHint = 50;
				lab_reportdquestion.setLayoutData(lab_reportdquestionLData);
				lab_reportdquestion.setText("\u904b\u52d5\u7fd2\u6163\u554f\u5377\u8cc7\u6599\u5206\u6790");
				lab_reportdquestion.setFont(SWTResourceManager.getFont("Tahoma", 26, 1, false, false));
				lab_reportdquestion.setSize(750, 50);
			}
			{
				but_reportdquestionsex = new Button(dataReportComposite, SWT.NONE);
				GridData but_reportdquestionsexLData = new GridData();
				but_reportdquestionsexLData.horizontalSpan = 2;
				but_reportdquestionsexLData.widthHint = 150;
				but_reportdquestionsexLData.heightHint = 100;
				but_reportdquestionsexLData.verticalAlignment = GridData.END;
				but_reportdquestionsex.setLayoutData(but_reportdquestionsexLData);
				but_reportdquestionsex.setText("\u6027\u5225\u5c0d\u6bd4\u5206\u6790");
				but_reportdquestionsex.setFont(SWTResourceManager.getFont("Tahoma", 16, 1, false, false));
				but_reportdquestionsex.setAlignment(SWT.CENTER);
				but_reportdquestionsex
				.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(SelectionEvent e) {
						try {
							previewReport.DQuestionnaireSexChartDisplay();
						} catch (Exception e1) {
							e1.printStackTrace();
						}
					}
				});
			}
			{
				lab_reportfquestion = new Label(dataReportComposite, SWT.NONE);
				GridData lab_reportfquestionLData = new GridData();
				lab_reportfquestionLData.horizontalSpan = 8;
				lab_reportfquestionLData.widthHint = 750;
				lab_reportfquestionLData.heightHint = 50;
				lab_reportfquestion.setLayoutData(lab_reportfquestionLData);
				lab_reportfquestion.setText("\u98f2\u98df\u7fd2\u6163\u554f\u5377\u8cc7\u6599\u5206\u6790");
				lab_reportfquestion.setFont(SWTResourceManager.getFont("Tahoma", 26, 1, false, false));
				lab_reportfquestion.setSize(750, 50);
			}
			{
				but_reportfquestionsex = new Button(dataReportComposite, SWT.NONE);
				GridData but_reportfquestionsexLData = new GridData();
				but_reportfquestionsexLData.horizontalSpan = 2;
				but_reportfquestionsexLData.widthHint = 150;
				but_reportfquestionsexLData.heightHint = 100;
				but_reportfquestionsexLData.verticalAlignment = GridData.END;
				but_reportfquestionsex.setLayoutData(but_reportfquestionsexLData);
				but_reportfquestionsex.setText("\u6027\u5225\u5c0d\u6bd4\u5206\u6790");
				but_reportfquestionsex.setFont(SWTResourceManager.getFont("Tahoma", 16, 1, false, false));
				but_reportfquestionsex.setAlignment(SWT.CENTER);
				but_reportfquestionsex
				.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(SelectionEvent e) {
						try {
							previewReport.FQuestionnaireSexChartDisplay();
						} catch (Exception e1) {
							e1.printStackTrace();
						}
					}
				});
			}
			{
				lab_reporttotal = new Label(dataReportComposite, SWT.NONE);
				GridData lab_reporttotalLData = new GridData();
				lab_reporttotalLData.horizontalSpan = 8;
				lab_reporttotalLData.widthHint = 750;
				lab_reporttotalLData.heightHint = 50;
				lab_reporttotal.setLayoutData(lab_reporttotalLData);
				lab_reporttotal.setText("\u7e3d\u9ad4\u8cc7\u6599\u5206\u6790");
				lab_reporttotal.setFont(SWTResourceManager.getFont("Tahoma", 26, 1, false, false));
				lab_reporttotal.setSize(750, 50);
			}
			{
				but_reporttotalsex = new Button(dataReportComposite, SWT.NONE);
				GridData but_reporttotalsexLData = new GridData();
				but_reporttotalsexLData.horizontalSpan = 2;
				but_reporttotalsexLData.widthHint = 150;
				but_reporttotalsexLData.heightHint = 100;
				but_reporttotalsexLData.verticalAlignment = GridData.END;
				but_reporttotalsex.setLayoutData(but_reporttotalsexLData);
				but_reporttotalsex.setText("\u6027\u5225\u5c0d\u6bd4\u5206\u6790");
				but_reporttotalsex.setFont(SWTResourceManager.getFont("Tahoma", 16, 1, false, false));
				but_reporttotalsex.setAlignment(SWT.CENTER);
				but_reporttotalsex
				.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(SelectionEvent e) {
						try {
							previewReport.OtherSexChartDisplay();
						} catch (Exception e1) {
							e1.printStackTrace();
						}
					}
				});
			}
		}
		
		return dataReportComposite;
	}
	
	public void tableYearGetData(){
		years.clear();
		years.add("All");
		years.addAll(getStudents.getAllYear(sno));
		for(String str : years){
			TableItem item = new TableItem(tabledataYear, SWT.NULL);
			item.setText(0, str);
		}
	}
	
	public void tableGradeGetData(){
		grades.clear();
		grades.add("All");
		grades.addAll(getStudents.getGradeByListYear(sno, getTableCheck(tabledataYear)));
		for(String str : grades){
			TableItem item = new TableItem(tabledataGrade, SWT.NULL);
			item.setText(0, str);
		}
	}
	
	public void tableClassGetData(){
		sclasses.clear();
		sclasses.add("All");
		sclasses.addAll(getStudents.getClassByListYearGrade(sno, getTableCheck(tabledataYear), getTableCheck(tabledataGrade)));
		for(String str : sclasses){
			TableItem item = new TableItem(tabledataClass, SWT.NULL);
			item.setText(0, str);
		}
	}
	
	public void tableStudentGetData(){
		studentstno.clear();
		studentstno.putAll(getStudents.getStudentStnoByListYearGradeClass(sno, getTableCheck(tabledataYear), getTableCheck(tabledataGrade), getTableCheck(tabledataClass)));
		TableItem item = new TableItem(tabledataStudent, SWT.NULL);
		item.setText(1, "All");
		item.setText(0, "All");
		for(String str : studentstno.keySet()){
			item = new TableItem(tabledataStudent, SWT.NULL);
			item.setText(1, studentstno.get(str));
			item.setText(0, str);
		}
	}
	
	public List<String> getTableCheck(Table table){
		List<String> returnList = new ArrayList<String>(); 
		for(TableItem tableItem : table.getItems()){
			if(tableItem.getChecked()){
				if(tableItem.getText(0).equals("All")){
					returnList.clear();
					returnList.add("%");
					break;
				}
				returnList.add(tableItem.getText(0));
			}
		}
		return returnList;
	}
}
